﻿define('position',
    ['ko','formActions'],
 function (ko, formActions) {
     var position = function () {
         var self = this;
         self.templateName = "position";
         self.deleteController = "/api/Positions/Delete/";
         self.id = ko.observable();
         self.code = ko.observable().extend({ validationEvent: "log: code" });
         self.title = ko.observable().extend({ validationEvent: "log: name" });
         self.createdOn = ko.observable();
         
         self.load = function(d) {
             self.id(d.id);
             self.code(d.code);
             self.title(d.title);
             self.createdOn(d.createdOn);
         };

         self.save = function() {
             toastr.success("Position saved");
         };
         
         var formAction = new formActions("/api/Positions/", self);
         self.validation = function () { formAction.validation(); };
         self.clearValidation = function () { formAction.clearValidation(); };
         self.save = function (parent, dlg) { formAction.save(parent, dlg); };
     };

     return position;

 });